<?php

class model_construct
{
	public function __construct($data) {
		$this->remplir_objet($data);
	}
	
	public function remplir_objet($data) {
		if(is_array($data)){
			foreach($data as $key => $value) {
				$method = 'set_' . $key;
				if(method_exists($this, $method)) {
					// permet d'eviter les problemes dues au type CLOB
					if(gettype($value) == 'object')
						$value = $value->load();
					call_user_func(array($this, $method), $value);
				}
			}
		}
	}
}

?>